﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.CMS263.PO;

namespace Com.CMS263.DAO
{
    public class UserRoleDAO
    {
        public void Add(UserRole userRole)
        {
            DBHelper.TransSaveOrUpdate(userRole);
        }
        public void UpdateRole(UserRole userRole)
        {
            DBHelper.TransSaveOrUpdate(userRole);
        }
        public void DeleteRoleByRoleID(int id)
        {
            DBHelper.ExecuteHQL("delete from UserRole where id="+id+"").ExecuteUpdate();
        }

        public IList<UserRole> GetAllRole()
        {
            return DBHelper.ExecuteHQL("from UserRole order by id desc ").List<UserRole>();
        }

        public bool isExist(string roleName)
        {
            return DBHelper.ExecuteHQL("from UserRole where roleName='"+roleName+"' ").List<UserRole>().Count>0;
        }
    }
}
